package mysocket;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
import java.util.Map;

public class Server {


    public static void main(String[] args) throws Exception {
        ServerSocket serverSocket = new ServerSocket(8001);
        Socket accept = null;

        Map<String, Socket> clientMap = new HashMap<>();

        int num = 1;

        while (true){
            accept = serverSocket.accept();
            if (accept != null){
                clientMap.put("client" + String.valueOf(num),accept);
                System.out.println("client" + num++ + "加入");
                new Thread(new STC(accept, clientMap)).start();
            }
        }
    }

}
